package wang.hu.bos.web.action;

import java.util.List;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;

import wang.hu.bos.domain.base.Standard;
import wang.hu.bos.service.StandardService;

import com.opensymphony.xwork2.ActionContext;

@Controller
@ParentPackage("json-default")
@Namespace("/")
@Scope("prototype")
public class StandardAction extends BaseAction<Standard> {
	@Autowired
	private StandardService standardService;

	private String ids;

	public String getIds() {
		return ids;
	}

	public void setIds(String ids) {
		this.ids = ids;
	}

	@Action(value = "standard_delBatch", results = { @Result(name = "success", type = "redirect", location = "./pages/base/standard.html") })
	public String delBatch() {
		standardService.updateSign(ids);
		return SUCCESS;
	}

	private Standard standard = new Standard();

	@Override
	public Standard getModel() {
		// TODO Auto-generated method stub
		return standard;
	}

	@Action(value = "standard_save", results = { @Result(name = "success", type = "redirect", location = "./pages/base/standard.html") })
	public String save() {
		standardService.save(model);
		standardService.save(standard);
		return SUCCESS;
	};

	// 取派标准分页查询
	@Action(value = "standard_pageQuery", results = { @Result(name = "success", type = "json") })
	public String standard_pageQuery() {

		Page<Standard> pagedata = standardService.findAll(page - 1, rows);
		pushPageableToValueStack(pagedata);
		return SUCCESS;
	}

	@Action(value = "standard_findAll", results = { @Result(name = "success", type = "json") })
	public String findAll() {
		List<Standard> list = standardService.findAllName();
		ActionContext.getContext().getValueStack().push(list);
		return SUCCESS;
	}

}
